package com.xxwu.mybatis.controller;

import com.xxwu.mybatis.model.userInfo;
import com.xxwu.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@RequestMapping("/UserController")
@RestController
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("/getData")
    public List<userInfo> getData() {
        return userService.getData();
    }
    @RequestMapping("/getDataByIdAndAge")
    public userInfo getDataByIdAndAge(int id, int age) {
        return userService.getDataByIdAndAge(1,18);
    }
    @RequestMapping("/getTime")
    public String getTime() {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String formattedTime = LocalDateTime.now().format(formatter);
        return "CurrentTime:" + formattedTime;
    }

}
